<html> 
<head>
<script>
    function doubleClickWord()
    {
        var start = document.getElementById("start");
        
        var x = start.offsetLeft + 2;
        var y = start.offsetTop + 10;
        
        eventSender.leapForward(1000);
        eventSender.mouseMoveTo(x, y);
        eventSender.mouseDown();
        eventSender.mouseUp();
        eventSender.leapForward(1);
        eventSender.mouseDown();
        eventSender.mouseUp();
        eventSender.leapForward(1000);
    }

    function logResult(result)
    {
        document.getElementById("result").innerHTML += result + "<br/>";
    }

    function runTests()
    {
        if (!window.eventSender || !window.testRunner || !window.internals)
            return;

        testRunner.dumpAsText();

        runTest("mac", "a paragraph");
        runTest("win", "paragra");
    }

    function runTest(behavior, expectedText)
    {
        internals.settings.setEditingBehavior(behavior);
        doubleClickWord();
        getSelection().modify("extend", "backward", "character");
        getSelection().modify("extend", "backward", "character");
        doubleClickWord();
        getSelection().modify("extend", "backward", "character");
        getSelection().modify("extend", "backward", "character");

        var selectedText = getSelection().toString();
        if (selectedText == expectedText)
            logResult("SUCCESS");
        else
            logResult("FAILURE: The selected text is \"" + selectedText + "\" and should be \"" + expectedText + "\".");
    }
</script>
</head>
<body onload="runTests()">
<p>This tests modifying a selection created with a double click with shift arrow key.</p>
<p style="color:green">
    This test does not run interactively.
    It uses the event sender to do mouse clicks.
    To run it manually, double click on the blue "g", then press shift-left-arrow twice.
    Then repeat those steps again.
    The selection should include the words "a paragraph" on mac and "paragra" on win/linux..
</p>
<p>This is a para<span style="color:blue" id="start">g</span>raph.</p>
<p id="result"></p>
</body>
